<template>
	<view class="cancellation">
		<view class="cancellation-input">
			<view class="cancellation-phone input">
				<text class="iconfont icon-phone"></text>
				<input type="number" v-model="phone" placeholder="请输入手机号" />
			</view>
			<view class="cancellation-pass input">
				<text class="iconfont icon-pass"></text>
				<input type="password" v-model="password" placeholder="请输入密码" />
			</view>
			<view class="btns">
				<view class="btn">
					<button type="default" :loading="loading" @click="cancellation()">注销</button>
				</view>
			</view>
		</view>
		<view class="rule">
			<view class="title">
				<text>知悉说明：</text>
			</view>
			<view class="rule-content">
				<text>1、账户注销后不可恢复</text>
				<text>2、账户注销后所有信息将被清除</text>
				<text>3、如：账户内有余额或可提现资产请提现完成后在进行注销操作</text>
				<text>4、注销账户表示认可非可提现资产（如：转客币）将会被默认划转到公益中心池和销毁中心池</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {cancellation} from "@/api/entrance.js"
	export default{
		name:"",
		data(){
			return{
				phone:"",
				password:"",
				loading:false
			}
		},
		methods:{
			async cancellation(){
				if(!this.phone){
					this.$msg("请输入账号")
					return;
				}
				if(!this.password){
					this.$msg("请输入密码")
					return;
				}
				uni.showModal({
					title: '提示',
					content: '请再次确实是否注销该账号',
					confirmColor: "#000000",
					success: async function(res) {
						if (res.confirm) {
							this.loading = true;
							let res = await cancellation({phone:this.phone,password:this.password})
							if(res.code === 1){
								this.loading = false;
								let userInfo = {
									avatar: "",
									create_time: 0,
									currency: 0,
									id: "",
									invitation_code: "",
									invitation_total: 0,
									isLogin: false,
									last_login_time: 0,
									parent_id: 0,
									phone: "",
									power: 0,
									reward_end_time: 0,
									reward_lord: 0,
									temporary_power: 0,
									username: "",
								};
								uni.removeStorageSync('oauth_token');
								this.setUserInfo_mutation(userInfo)
								setTimeout(()=>{
									uni.navigateTo({
										url: '/pages/entrance/login/login'
									})
								},1000)
							}
							this.$msg(res.msg)
						}
					}
				})
			}
		}
	}
</script>

<style lang="less" scoped src="./cancellation.less">
</style>
